# raise 主动抛出异常
# abort 在网页中主动抛出异常
from flask import Flask,abort,request,make_response,render_template

app = Flask(__name__)

@app.route('/index',methods = ['GET','POST'])
def index():
    if request.method =='GET':
        return render_template('index.html')
    if request.method == 'POST':
        name = request.form.get('name')
        password = request.form.get('password')
        if name == 'zhangsan' and password == '123':
            return 'login success'
        else:
            make_response('信息错误')
            abort(404)
            return '信息错误'
    return '123'

# 自定义错误处理方式
@app.errorhandler(404)
def handle_404_error(err):
    return render_template('404.html')

if __name__ == '__main__':
    app.run()